package com.nuaa.ange.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.nuaa.ange.annotation.ApiLog;
import com.nuaa.ange.common.lang.RespBean;
import com.nuaa.ange.entity.ReplyPic;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @description
 * @author 玦离
 * @date 2023/1/1 19:00
 */

@RestController
@Api(tags = "评论图片相关接口")
@RequestMapping("/reply-pic")
public class ReplyPicController extends BaseController{

    @ApiOperation(value = "评论所有图片")
    @GetMapping("/get")
    @ApiLog
    public List<ReplyPic> getAllPicByAid(@RequestParam("replyId") int replyId) {
        return replyPicService.list(new QueryWrapper<ReplyPic>()
                .eq("reply_id", replyId));
    }

    @ApiOperation(value = "删除评论图片")
    @GetMapping("/delete")
    @ApiLog
    public RespBean deletePic(@RequestParam("replyId") int articleId) {
        replyPicService.remove(new QueryWrapper<ReplyPic>()
                .eq("reply_id", articleId));
        return RespBean.ok("删除图片成功");
    }

}
